﻿'''
Created on 2010-4-10

@author: Kevincat
'''
import math

class TheoreticalModel():
	def __init__(self):
		self.frequency = 2400 # f with the unit of MHz and f = 2.4GHz
		self.length = 4000 # unit : mm
		self.width = 4000 # unit : mm
		self.sampleSize = 50
		self.genPoints()
		
	def getDistance(self, x, y):
		# assume the ap in (0, 0)
		return math.sqrt(x*x + y*y)
		
	def getLoss(self, d, f):
		return 32.44 + 20*math.log10(d/1000000) + 20*math.log10(f);
		
	def genPoints(self):
		s = self.sampleSize
		self.p = []
		for x in range(1, self.length/s):
			for y in range(1, self.width/s):
				self.p.append({'x':x*s, 'y':y*s})
	
	def printLoss(self):
		for p in self.p:
			d = self.getDistance(p['x'], p['y'])
			loss = self.getLoss(d, self.frequency)
			print 'point: x = ' + str(p['x']) + ', y = ' + str(p['y']) + ', loss = ' + str(loss)			
			
if __name__ == "__main__":
   t = TheoreticalModel()
   t.printLoss()